package com.woniu.order.controller;


import com.woniu.exception.userexp.YogaException;
import com.woniu.model.Result;
import com.woniu.order.model.GoodsItem;
import com.woniu.order.service.GoodsItemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 杜岷芫
 * @since 2024年07月12日
 */
@RestController
@RequestMapping("/goodsItem")
@Api(tags = "查询多个订单信息")
public class GoodsItemController {
    @Resource
    private GoodsItemService goodsItemService;

    /**
     * 通过订单ID查询多个订单信息
     * @param orderNum 订单编号
     * @return
     * @throws YogaException
     */
    @PostMapping("/listOrderItem")
    @ApiOperation(value = "通过订单ID查询多个订单信息")
    public Result<List<GoodsItem>> listByClassType(@RequestBody String orderNum) throws YogaException {
        List<GoodsItem> goodsItems = goodsItemService.listByClassType(orderNum);
        return Result.getListResult(GoodsItem.class).setData(goodsItems).setCode(200).setMsg("查询成功");
    }
}

